#ifndef CC_YMODEM_PUBLIC_H
#define CC_YMODEM_PUBLIC_H

// #include "cc_type.h"
#include "basic_api.h"
#include "Mode.h"

/* 基本配置参数 定义
  帧格式 SOH/STX + seq + payload + crc 
	RYM == "Real-YModem". 
*/
enum rym_code {
    RYM_CODE_NONE = 0x00,
    RYM_CODE_SOH  = 0x01,
    RYM_CODE_STX  = 0x02,
    RYM_CODE_EOT  = 0x04,
    RYM_CODE_ACK  = 0x06,
    RYM_CODE_NAK  = 0x15,
    RYM_CODE_CAN  = 0x18,
    RYM_CODE_C    = 0x43,
};

#define RYM_MIN_SZ 		(5)
#define RYM_SOH_PKG_SZ (1+2+128+2)
#define RYM_STX_PKG_SZ (1+2+1024+2)

#define RYM_SOH_DATA_SZ (128)
#define RYM_STX_DATA_SZ (1024)

//
#define CFG_FILESZ_FORMAT_HEXSTR			1 // 
#define CFG_YM_RPKG_ONLY_128 				1 // 设置紧使用128byte长数据 以节约buf空间

// 
#define CFG_RECO_YM	// open Reco Mode
#ifdef CFG_RECO_YM				
typedef struct CC_YModem_Ptcl_Recognition tReco_YModem;

extern tReco_YModem* RecoYM_SCreate(uint16_t BufSz);
extern int RecoYM_Set_MsTimOut(tReco_YModem* pObj,uint32_t Para_TimeOut);
extern int RecoYM_BindParser(tReco_YModem* pObj,int (*pPkgParser)(uint32_t ,uint8_t* ));
extern int RecoYM_Recognizer(void* pObj,uint8_t ch);

#endif

#define CFG_YMS	
#ifdef CFG_YMS
extern uint32_t HexStrToU32(uint8_t* pStr);
extern uint32_t DecStrToU32(uint8_t* pStr);
#endif

#define CFG_YMM	
#ifdef CFG_YMM
extern uint16_t Calc_CRC16_ByByte(uint16_t crc,unsigned char ch);
extern uint16_t Calc_Pkg_CRC16(uint16_t InitCRC,uint16_t Len,uint8_t* pPkg);
extern int u32ToHexStr(uint32_t Val,uint8_t* pRbuf);
extern int u32ToDecStr(uint32_t Val,uint8_t* pRbuf);
#endif


#endif

